Totals
Hi,
I create a simply Total, but when I am trying to asign it to TextObject, it doesn't work. This is part of my code:
The error message is "The name "totalKm" doesn't exist in the current content". So I realize, that I have to add it to my Report:
But this don't work. I've even try this:
but I've got Exception "System.NullReferenceException: Object reference not set to an instance of an object", so I think that the value of my Total is null.
What should I do? Is there any way to 'activate' Total? Maybe in the EventHandler --> text.AfterData(or after/before something)?
The main thing is, that all that calculating is in the loop, I don't know how many times it goes and I don't know number of columns. The Totals needs to be dynamically defined and used (columns too), so I need to programm in code, instead of Drag&Drop (and click).
I appreciate for all help, even the little one
I create a simply Total, but when I am trying to asign it to TextObject, it doesn't work. This is part of my code:
Total totalKm = new Total();
totalKm.Name = "totalKm";
totalKm.Evaluator = Data1;
totalKm.Expression = "[dt1.KM]";
totalKm.PrintOn = GroupFooter1;
totalKm.TotalType = TotalType.Sum;
TextObject text = new TextObject();
text.Text = "[totalKm]";
The error message is "The name "totalKm" doesn't exist in the current content". So I realize, that I have to add it to my Report:
Report.Dictionary.Totals.Add(totalKm);
But this don't work. I've even try this:
text.Text = totalKm.Value.ToString();
but I've got Exception "System.NullReferenceException: Object reference not set to an instance of an object", so I think that the value of my Total is null.
What should I do? Is there any way to 'activate' Total? Maybe in the EventHandler --> text.AfterData(or after/before something)?
The main thing is, that all that calculating is in the loop, I don't know how many times it goes and I don't know number of columns. The Totals needs to be dynamically defined and used (columns too), so I need to programm in code, instead of Drag&Drop (and click).
I appreciate for all help, even the little one
Comments
1. I've created manually couple of Totals in Data --> RMB --> Create Total, but without expression
2. In code (in loop) I changed the expression dynamically, like this:
Of course columns in my data 'dt1' are named Col1, Col2, depends on number 'max'.
I've got another question - How do I change Format of TextBox in code? text.Format = ?? What do I have t oassign to it?